using System;
using System.Net;
using Microsoft.TeamFoundation.Client;

namespace BuildStatusIndicator.Controller.TfsConnectionStatergy
{
    public class UsernameConnectinonStratergy : ConnectinonStatergyBase
    {
        private readonly string _password;
        private readonly string _username;

        public UsernameConnectinonStratergy(string serverUrl, string teamProject, uint pollingIntervall,
                                                      string username,
                                                      string password)
            : base(serverUrl, teamProject, pollingIntervall)
        {
            _username = username;
            _password = password;
        }

        public string Username
        {
            get { return _username; }
        }

        public string Password
        {
            get { return _password; }
        }

        protected override TeamFoundationServer Connect()
        {
            return new TeamFoundationServer(ServerUrl, new NetworkCredential(Username, Password));
        }
    }
}